package com.spzx.product.api;

import com.spzx.common.core.constant.SecurityConstants;
import com.spzx.common.core.constant.ServiceNameConstants;
import com.spzx.common.core.domain.R;
import com.spzx.product.api.domain.SkuLockVo;
import com.spzx.product.api.fallback.RemoteSkuStockFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;

import java.util.List;

@FeignClient(
            contextId = "remoteSkuStockService",
            value = ServiceNameConstants.PRODUCT_SERVICE,
            fallbackFactory = RemoteSkuStockFallbackFactory.class
    )
    public interface RemoteSkuStockService {

        @PostMapping("/skuStock/checkAndLock/{orderNo}")
        R<String> checkAndLock(
                @PathVariable("orderNo") String orderNo,
                @RequestBody List<SkuLockVo> skuLockVoList,
                @RequestHeader(SecurityConstants.FROM_SOURCE) String source
        );
    }